home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.03 Mar 89 / calc source / DoMouse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-12-09  |  2.4 KB  |  89 lines  |  [TEXT/KAHL]

  1.  
  2. #include <WindowMgr.h>
  3. #include <ListMgr.h>
  4. #include <OSUtil.h>
  5. #include <EventMgr.h>
  6.  
  7. #include "MacCalc.h"
  8. #include "SheetHndlg.h"
  9. #include "CalcData.h"
  10.  
  11. WindowPtr curr_window_ptr ;
  12.  
  13. void DoMouseDown( ev )
  14. EventRecord *ev ;
  15. {
  16.     SHEET_WIN_HDL sheet_record_hdl ;
  17.     Point new_point ;
  18.     int location ;
  19.     GrafPtr tmp_port ;
  20.     Rect boundsRect ;
  21.     long newsize ;
  22.     long menuchoice ;
  23.     int width, heigth ;
  24.     union {
  25.         long tmp ;
  26.         Cell last_cell ;
  27.     } a ;
  28.     
  29.     location = FindWindow( ev->where, &curr_window_ptr ) ;
  30.     
  31.     if( ( curr_window_ptr != FrontWindow( ) ) && ( curr_window_ptr != NULL ) ) {
  32.         SelectWindow( curr_window_ptr ) ;
  33.         return ;
  34.     }
  35.     
  36.     new_point = ev->where ;
  37.     GetPort( &tmp_port ) ;
  38.     SetPort( curr_window_ptr ) ;
  39.     GlobalToLocal( &new_point ) ;
  40.     
  41.     switch( location ) {
  42.     case inDesk:
  43.         break ;
  44.     case inMenuBar:
  45.         menuchoice = MenuSelect( ev->where ) ;
  46.         if( HiWord( menuchoice ) == FILE_MENU ) {
  47.             quit_flag = TRUE ;
  48.         }
  49.         HiliteMenu( 0 ) ;
  50.         break ;
  51.     case inContent:
  52.         sheet_record_hdl = (SHEET_WIN_HDL)GetWRefCon( curr_window_ptr ) ;
  53.         if( LClick( new_point, ev->modifiers, (**sheet_record_hdl).sheet_list_hdl ) ) {
  54.             a.tmp = LLastClick( (**sheet_record_hdl).sheet_list_hdl ) ;
  55.             EnterData( a.last_cell, sheet_record_hdl ) ;
  56.         }
  57.         DrawGrid( curr_window_ptr ) ;
  58.         break ;
  59.     case inDrag:
  60.         boundsRect = curr_screen ;
  61.         DragWindow( curr_window_ptr, ev->where, &boundsRect ) ;
  62.         break ;
  63.     case inGrow:
  64.         sheet_record_hdl = (SHEET_WIN_HDL)GetWRefCon( curr_window_ptr ) ;
  65.         newsize = GrowWindow( curr_window_ptr, ev->where, &minmax_size ) ;
  66.         if( newsize ) {
  67.             width = ( ( LoWord( newsize ) / CELL_WIDTH ) * CELL_WIDTH ) + 15 ;
  68.             heigth = ( ( HiWord( newsize ) / CELL_HEIGTH ) * CELL_HEIGTH ) + 15 ;
  69.             SizeWindow( curr_window_ptr, width, heigth, TRUE ) ;
  70.             LSize( width-15, heigth-15, (**sheet_record_hdl).sheet_list_hdl ) ;
  71.             DrawGrid( curr_window_ptr ) ;
  72.             DrawGrowIcon( curr_window_ptr ) ;
  73.         }
  74.         break ;
  75.     case inGoAway:
  76.         if( TrackGoAway( curr_window_ptr, ev->where ) ) {
  77.             quit_flag = TRUE ;
  78.         }
  79.         break ;
  80.     }
  81.     SetPort( tmp_port ) ;
  82.  
  83.     return ;
  84. }
  85. int ClikLoop( )
  86. {
  87.     DrawGrid( curr_window_ptr ) ;
  88.     return TRUE ;
  89. }